package SocketTest;

import javax.swing.plaf.IconUIResource;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class QQServer {
    public static void main(String[] args) {
         byte[] bytes = new byte[1024];
        try {
            ServerSocket serverSocket = new ServerSocket();
            serverSocket.bind(new InetSocketAddress(8080));

            while (true) {
                System.out.println("wait conn");
                //阻塞
                Socket socket = serverSocket.accept();
                //阻塞 read读了多少字节
                System.out.println("wait data");

                int read = socket.getInputStream().read(bytes);

                String content = new String(bytes);

                System.out.println(content);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
